package @modelPackage@;

import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;

/**
 * Singleton that represents manager for session factory object   *
 * @author Michal Rost
 */
public class SessionFactoryManager {

  private static final SessionFactory factory;
  static {
    try {
      factory = new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) {
      System.err.println("Initial SessionFactory creation failed." + ex);
      throw new ExceptionInInitializerError(ex);
    }
  }

  /**
   * Returns factory
   * @return factory
   */
  public static SessionFactory getFactory() {
    return factory;
  }
}
